package org.apix;

import java.util.logging.Logger;

import org.apix.commands.CommandProcessor;

import org.apix.events.EntityExplodeListner;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Event;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.martin.bukkit.npclib.NPCManager;

public class Apix extends JavaPlugin {

	public static Apix plugin;
	public ApixPlayerListener playerListener = new ApixPlayerListener(this);
	
	public static Logger log = Logger.getLogger("Minecraft");	
	
	ChatColor white = ChatColor.WHITE;
	ChatColor red = ChatColor.RED;
	
	private CommandProcessor cmdProcessor;
	private CooldownManager cooldownManager;
	
	private NPCManager npcManager;
	
	@Override
	public void onDisable() {
		log.info("Apix disabled");  		
	}	
	
	

	@Override
	public void onEnable() {
		PluginManager pm = getServer().getPluginManager();
		
		 pm.registerEvent(Event.Type.ENTITY_EXPLODE, new EntityExplodeListner(this), Event.Priority.Monitor, this);
		//pm.registerEvent(Event.Type.PLAYER_RESPAWN, playerListener, Priority.Highest, this);
		//pm.registerEvent(Event.Type.PLAYER_JOIN,  playerListener, Priority.Normal, this);
		//pm.registerEvent(Event.Type.PLAYER_INTERACT,  playerListener, Priority.Monitor, this);
		//pm.registerEvent(Event.Type.PLAYER_QUIT,  playerListener, Priority.High, this);
		//pm.registerEvent(Event.Type.PLAYER_KICK,  playerListener, Priority.High, this);
		
		cooldownManager = new CooldownManager(this);
		cmdProcessor = new CommandProcessor(this);
		
		npcManager = new NPCManager(this);		
		log.info("Apix is enabled");
	}
	
	 @Override
	    public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
		 	
	    	return cmdProcessor.onCommand(sender, command, commandLabel, args);
	    }
	
	 public NPCManager getManager() {
		 return this.npcManager;
	 }
	
	public CooldownManager getCooldownManager() { return cooldownManager; }	
	@Override
    public ClassLoader getClassLoader() { return super.getClassLoader(); }
	
}
